
<%@ page import="institutional.Course" %>
<!doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="layout" content="kickstart" />
	<g:set var="entityName" value="${message(code: 'course.label', default: 'Course')}" />
	<title><g:message code="default.list.label" args="[entityName]" /></title>
</head>

<body>
	
<section id="list-course" class="first">

	<table class="table table-bordered">
		<thead>
			<tr>
			
				<th><g:message code="course.subject.label" default="Subject" /></th>
			
				<th><g:message code="course.professor.label" default="Professor" /></th>
			
				<g:sortableColumn property="size" title="${message(code: 'course.size.label', default: 'Size')}" />
				
				<g:sortableColumn property="size" title="${message(code: 'course.remaining.places.label', default: 'Remaining Places')}" />
				
				<g:sortableColumn property="timetable" title="${message(code: 'course.timetable.label', default: 'Timetable')}" />
				
				<shiro:lacksRole name="STUDENT_ROLE">
				<g:sortableColumn property="available" title="${message(code: 'course.available.label', default: 'Available')}" />
				</shiro:lacksRole>
			
				<g:sortableColumn property="dateOfCreation" title="${message(code: 'course.dateOfCreation.label', default: 'Date Of Creation')}" />
				<shiro:hasRole name="STUDENT_ROLE">
				<th><g:message code="course.subject.enrol" default="Enrol To Course" /></th>
				</shiro:hasRole>
			</tr>
		</thead>
		<tbody>
		<g:each in="${courseInstanceList}" status="i" var="courseInstance">
			<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
			
				<td><g:link action="show" id="${courseInstance.id}">${fieldValue(bean: courseInstance, field: "subject")}</g:link></td>
			
				<td>${fieldValue(bean: courseInstance, field: "professor")}</td>
			
				<td>${fieldValue(bean: courseInstance, field: "size")}</td>
				
				<td>${courseInstance.getRemainingSpots()}</td>
				
				<td>${fieldValue(bean: courseInstance, field: "timetable")}</td>
				
				<shiro:lacksRole name="STUDENT_ROLE">
				<td><g:formatBoolean boolean="${courseInstance.available}" /></td>
				</shiro:lacksRole>
				<td><g:formatDate date="${courseInstance.dateOfCreation}" /></td>
				
				<shiro:hasRole name="STUDENT_ROLE">
				<td><g:link action="createInscriptionToCourse" params="[courseId:courseInstance.id]">Enrol</g:link></td>
				</shiro:hasRole>
			</tr>
		</g:each>
		</tbody>
	</table>
	<div class="pagination">
		<bs:paginate total="${courseInstanceTotal}" />
	</div>
</section>

</body>

</html>
